// 引入一级路由组件
// import Search from "../pages/Search";
// import Login from "../pages/Login";
// import Register from "../pages/Register";
// import Detail from "../pages/Detail";
// import AddCartSuccess from '../pages/AddCartSuccess'
// import ShopCart from '../pages/ShopCart'
// import Trade from '../pages/Trade'
// import Pay from '../pages/Pay'
// import PaySuccess from '../pages/PaySuccess'
// import Center from '../pages/Center'
// 引入二级路由组件
// import MyOrder from '../pages/Center/myOrder'
// import GroupOrder from '../pages/Center/groupOrder'
export default [
  // 重定向，在项目跑起来的时候，访问/。立马让他定向到首页
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/home",
    name: "Home",
    component: () => import('@/pages/Home'),
    meta: {
      showFooter: true
    },
  },
  {
    path: "/search/:keyword?",
    name: "Search",
    component: () => import('@/pages/Search'),
    meta: {
      showFooter: true
    },
  },
  {
    path: "/login",
    name: "Login",
    component: () => import('@/pages/Login'),
    meta: {
      showFooter: false
    },
  },
  {
    path: "/register",
    name: "Register",
    component: () => import('@/pages/Register'),
    meta: {
      showFooter: false
    },
  },
  {
    path: "/detail/:skuId?",
    name: "Detail",
    component: () => import('@/pages/Detail'),
    meta: {
      showFooter: true
    },
  },
  {
    path: "/addCartSuccess",
    name: "AddCartSuccess",
    component: () => import('@/pages/AddCartSuccess'),
    meta: {
      showFooter: true
    },
  },
  {
    path: "/shopCart",
    name: "ShopCart",
    component: () => import('@/pages/ShopCart'),
    meta: {
      showFooter: true
    },
  },
  {
    path: "/trade",
    name: "Trade",
    component: () => import('@/pages/Trade'),
    meta: {
      showFooter: true,
      isAuth: true,
    },
    beforeEnter: (to, from, next) => {
      if (to.path == "shopCart") {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    path: "/pay",
    name: "Pay",
    component: () => import('@/pages/Pay'),
    meta: {
      showFooter: true,
      isAuth: true,
    },
    beforeEnter: (to, from, next) => {
      if (to.path == '/trade') {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    path: "/paysuccess",
    name: "PaySuccess",
    component: () => import('@/pages/PaySuccess'),
    meta: {
      showFooter: true
    },
    beforeEnter: (to, from, next) => {
      if (to.path == '/pay') {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    path: "/center",
    name: "Center",
    component: () => import('@/pages/Center'),
    meta: {
      showFooter: true,
      isAuth: true,
    },

    children: [{
        path: 'myOrder',
        name: 'MyOrder',
        component: () => import('@/pages/Center/myOrder'),
        meta: {
          showFooter: true,
          isAuth: true,
        },
      },
      {
        path: 'groupOrder',
        name: 'GroupOrder',
        component: () => import('@/pages/Center/groupOrder')
      },
      {
        path: '/center',
        redirect: '/center/myOrder',
      }
    ]
  },
];